const { regClass } = Laya;
import { PopupCommonYesNoBase } from "./PopupCommonYesNo.generated";

@regClass()
export class PopupCommonYesNo extends PopupCommonYesNoBase {
    actYes:()=>void;
    actNo:()=>void;

    onAwake(): void {
        this.btnCancle.on(Laya.Event.CLICK, this, this.onClickCancleBtn);
        this.btnConfirm.on(Laya.Event.CLICK, this, this.onClickConfirmBtn);
    }
    onDestroy(): void {
        this.btnCancle.off(Laya.Event.CLICK, this, this.onClickCancleBtn);
        this.btnConfirm.off(Laya.Event.CLICK, this, this.onClickConfirmBtn);
    }
    public showPop(msg:string , actYes:()=>void,actNo:()=>void){
        this.actYes = actYes;
        this.actNo = actNo;
        this.txtMsg.text = msg;
        this.visible = true;
    }
    public hidePop() {
        this.visible = false;
    }

    private onClickCancleBtn() {
        this.hidePop();
        this.actNo?.();
        this.actYes = undefined; 
        this.actNo = undefined;
    }
    private onClickConfirmBtn() {
        this.hidePop();
        this.actYes?.();
        this.actYes = undefined; 
        this.actNo = undefined;
    }
}